package xiangmu.schoolpaper.service.impl.system;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import xiangmu.schoolpaper.mapper.system.GetTeacherMapper;
import xiangmu.schoolpaper.pojo.VO.GetTeacherVO;
import xiangmu.schoolpaper.service.system.GetTeacherService;

import java.util.ArrayList;
import java.util.List;

@Service
public class GetTeacherServiceImpl implements GetTeacherService {
    @Autowired
    public GetTeacherMapper getTeacherMapper;

    @Override
    public List<String> getAllYearsByMajor(String major){
        List<String> years =getTeacherMapper.getAllYearsByMajor(major);
        return years;
    }
    @Override
    public List<String> getyearByteacher(String teacher){
        List<String > getteacher = getTeacherMapper.getyearByteacher(teacher);
        //抽取出所有的年，重新组成一个集合然后返回这个集合即可
        List<String > year=new ArrayList<>();
        for (String s : getteacher) {
            String[] split = s.split("-");
            // 截取split数组第一个元素的前4个字符
            split[0]=split[0].substring(0,4);
            year.add(split[0]);
        }
        return  year;
    }
    @Override
    public List<String> getteacherByyear(Integer year){
        List<String> getteacher = getTeacherMapper.getteacherByyear(year);
        return getteacher;
    }
}
